//
//  VC_Regist.m
//  yjw-winner
//
//  Created by 王春辉 on 2018/9/15.
//  Copyright © 2018年 Shanghai decade financial information service co., LTD. All rights reserved.
//

#import "VC_Regist.h"
#import "VC_RegistWriteCode.h"

@interface VC_Regist ()
@property (weak, nonatomic) IBOutlet UIImageView *headImageView;
@property (weak, nonatomic) IBOutlet UITextField *phoneTextField;
@property (weak, nonatomic) IBOutlet UIButton *registButton;
@property (weak, nonatomic) IBOutlet UIButton *agreeButton;

@property (nonatomic, assign) BOOL isAgress;
@property (nonatomic, assign) BOOL isRightNumber;
@end

@implementation VC_Regist

- (void)viewDidLoad {
    [super viewDidLoad];
    self.headImageView.layer.masksToBounds = YES;
    self.headImageView.layer.cornerRadius = self.headImageView.mj_w * 0.5;
    
    self.registButton.layer.masksToBounds = YES;
    self.registButton.layer.cornerRadius = 4.0f;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark --mark EVENT

- (IBAction)agressButtonClick:(UIButton *)sender {
    sender.selected = !sender.selected;
    self.isAgress = sender.isSelected;
}
- (IBAction)registButtonClick:(UIButton *)sender {
    self.isRightNumber = [self.phoneTextField.text isAvailablePhoneNumber];
    if (self.isAgress && self.isRightNumber) {
        // 注册 下一步
        VC_RegistWriteCode *vc = [[UIStoryboard storyboardWithName:@"LoginStoryBoard" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:NSStringFromClass([VC_RegistWriteCode class])];
        vc.phoneNmber = self.phoneTextField.text;
        [self.navigationController pushViewController:vc animated:YES];
    }else if (!self.isAgress){
        [MBProgressHUD showSuccess:@"请遵守用户协议"];
    }else {
        [MBProgressHUD showSuccess:@"请填写正确的电话号码"];
    }
}

@end
